The C++ compiler flags as an error the use of member function pointers with objects that might not recognize the pointer or its contents. Here's an example of such errors:
class Mammal { public: void f(int); };
class Cat : public Mammal { public: void f(int); };
void g (Cat* aCat, Mammal* aMammal) {
void (Mammal::*mammal_f_ptr)(int) = &Mammal::f;
void (Cat::*cat_f_ptr)(int) = &Cat::f;
(aCat->*mammal_f_ptr)(4); // OK
(aMammal->*cat_f_ptr)(5); // Error (1)
cat_f_ptr = &Cat::f; // OK
mammal_f_ptr = &Cat::f; // Error (2)
}
The local variables mammal_f_ptr and cat_f_ptr are pointers to member functions, and the function g initializes them to point to the class Cat member function f . It then attempts to invoke this function through these pointers. Statement (1) is an error because you can't be sure that a Mammal object, aMammal , "responds to" a Cat member pointer, cat_f_ptr --especially since cat_f_ptr points to a Cat member function that Mammal would know nothing about. Even if cat_f_ptr were initialized to a Mammal member function, cat_f_ptr cannot safely be applied to a Mammal object. The assignment in (2) is an error because you cannot be sure that some member function of a derived class (in this case Cat::f ) is available in any of its base classes (in this case Mammal ).